%%
%% %CopyrightBegin%
%%
%% Copyright Hillside Technology Ltd. 2016. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%%     http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%
%% %CopyrightEnd%
%%

%% This file was generated by soap:wsdl2erlang, but after that the header_parser 
%% callback was added, in order to test that functionality.

%% generated by soap from: e:/e_soap/soap/test/soap_SUITE_data/test_service.wsdl
%% for service "test_service" and port "test_port"
%% using options: [{service,"test_service"},{port,"test_port"},{generate,client},{namespaces,[{"test",undefined}]},{http_client,soap_client_ibrowse},{client_name,"test_service_client"}]

-module(test_service_client).

-include("test_service.hrl").

-export([interface/0]).
-export([header_parser/1]).

%% The functions that are described by the WSDL
-export([do_test/3]).

-spec do_test(Soap_body::request_body(),
    Soap_headers::[soap:soap_header()],
    Options::[any()]) -> soap:soap_handler_response(response_body()).
do_test(Soap_body, Soap_headers, Options) ->
    soap_client_util:call(Soap_body, Soap_headers, Options, "\"do_test\"", 
                          interface()).

%% Parse headers from the "test" namespace using the data mapper; Parse 
%% headers from other namespaces using the `map()` parser (translate to a map).
-spec header_parser(Namespace::string()) 
    -> {ok, {fun((Event::erlsom:sax_event(), State::any()) -> any()), any()}}.
header_parser("") ->  
    {ok, soap_parsers:skip(undefined)};
header_parser("test") ->  
    Model = soap_interface:model(interface()),
    {ok, soap_parsers:data_mapper(Model)};
header_parser(_) ->  
    {ok, soap_parsers:map()}.

%%% --------------------------------------------------------------------
%%% Internal functions
%%% --------------------------------------------------------------------
interface() ->
    ?INTERFACE.
